<?php
ini_set("display_errors", "On");
error_reporting(E_ALL | E_STRICT);
include 'config.php';
$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
if (!$mysqli->set_charset("utf8")) {}

$minDay=10;
if ($_GET['day']){
    $minDay=$_GET['day'];
}

$time=time()-60*60*24*$minDay;
$theday=date("Y-m-d",$time);
echo $theday;
echo "<br />";

$lianXi=array();

$sqlPv="SELECT count(openid) as c FROM `baidu` ";
$sqlUv="SELECT count(DISTINCT openid) c FROM `baidu` ";

$ziDian=array(
    'kswd'=>'进入开始问答测试页',
    'jrysly'=>'进入艺术疗愈页',
    'yslyqy'=>'艺术疗愈起源页',
    'whsys'=>'艺术疗愈为何是艺术',
    'xmdlx'=>'艺术疗愈下面的练习可以帮助你',
    'lx1'=>'进入练习一',
    'lx2'=>'进入练习二',
    'lx3'=>'进入练习三',
    'lx4'=>'进入练习四',
    'lx5'=>'进入练习五',
    'lx6'=>'进入练习六',
    'saveimage1'=>'练习一保存图片',
    'saveimage2'=>'练习二保存图片',
    'saveimage4'=>'练习四保存图片',
);

$riQiWhere="  and `createtime` LIKE '%".$theday."%'  ";
$query=$mysqli->query($sqlPv." WHERE `name` LIKE '艺术疗愈按钮' ".$riQiWhere." ");
$getPv=$query->fetch_assoc();
$query=$mysqli->query($sqlUv." WHERE `name` LIKE '艺术疗愈按钮' ".$riQiWhere." ");
$getUv=$query->fetch_assoc();
$lianXi['kswd']=array('pv'=>$getPv['c'],'uv'=>$getUv['c']);

 
$query=$mysqli->query($sqlPv." WHERE `name` LIKE '艺术疗愈起源' ".$riQiWhere." ");
$getPv=$query->fetch_assoc();
$query=$mysqli->query($sqlUv." WHERE `name` LIKE '艺术疗愈起源' ".$riQiWhere." ");
$getUv=$query->fetch_assoc();
$lianXi['yslyqy']=array('pv'=>$getPv['c'],'uv'=>$getUv['c']);


echo '............',"<br /><br /><br /><br />";
var_dump($lianXi);

 
$riQiWhere="  and `createtime` LIKE '%".$theday."%'  ";
$query=$mysqli->query($sqlPv." WHERE `name` LIKE '进入艺术疗愈' ".$riQiWhere." ");
$getPv=$query->fetch_assoc();
$query=$mysqli->query($sqlUv." WHERE `name` LIKE '进入艺术疗愈' ".$riQiWhere." ");
$getUv=$query->fetch_assoc();
$lianXi['jrysly']=array('pv'=>$getPv['c'],'uv'=>$getUv['c']);


var_dump($getPv);

echo '............',"<br />";

var_dump($getUv);

echo '............',"<br /><br /><br /><br />";





$query=$mysqli->query($sqlPv." WHERE `name` LIKE '为何是艺术' ".$riQiWhere." ");
$getPv=$query->fetch_assoc();
$query=$mysqli->query($sqlUv." WHERE `name` LIKE '为何是艺术' ".$riQiWhere." ");
$getUv=$query->fetch_assoc();
$lianXi['whsys']=array('pv'=>$getPv['c'],'uv'=>$getUv['c']);


$query=$mysqli->query($sqlPv." WHERE `name` LIKE '艺术疗愈下面的练习' ".$riQiWhere."  ");
$getPv=$query->fetch_assoc();
$query=$mysqli->query($sqlUv." WHERE `name` LIKE '艺术疗愈下面的练习' ".$riQiWhere." ");
$getUv=$query->fetch_assoc();
$lianXi['xmdlx']=array('pv'=>$getPv['c'],'uv'=>$getUv['c']);
 
 

  
$query=$mysqli->query($sqlPv." WHERE `name` LIKE '进入练习一' ".$riQiWhere." ");
$getPv=$query->fetch_assoc();
$query=$mysqli->query($sqlUv." WHERE `name` LIKE '进入练习一' ".$riQiWhere." ");
$getUv=$query->fetch_assoc();
$lianXi['lx1']=array('pv'=>$getPv['c'],'uv'=>$getUv['c']);


$query=$mysqli->query($sqlPv." WHERE `name` LIKE '进入练习二' ".$riQiWhere." ");
$getPv=$query->fetch_assoc();
$query=$mysqli->query($sqlUv." WHERE `name` LIKE '进入练习二' ".$riQiWhere." ");
$getUv=$query->fetch_assoc();
$lianXi['lx2']=array('pv'=>$getPv['c'],'uv'=>$getUv['c']);

$query=$mysqli->query($sqlPv." WHERE `name` LIKE '进入练习三' ".$riQiWhere." ");
$getPv=$query->fetch_assoc();
$query=$mysqli->query($sqlUv." WHERE `name` LIKE '进入练习三' ".$riQiWhere." ");
$getUv=$query->fetch_assoc();
$lianXi['lx3']=array('pv'=>$getPv['c'],'uv'=>$getUv['c']);
 
$query=$mysqli->query($sqlPv." WHERE `name` LIKE '进入练习四' ".$riQiWhere." ");
$getPv=$query->fetch_assoc();
$query=$mysqli->query($sqlUv." WHERE `name` LIKE '进入练习四' ".$riQiWhere." ");
$getUv=$query->fetch_assoc();
$lianXi['lx4']=array('pv'=>$getPv['c'],'uv'=>$getUv['c']);
 
$query=$mysqli->query($sqlPv." WHERE `name` LIKE '进入练习五' ".$riQiWhere." ");
$getPv=$query->fetch_assoc();
$query=$mysqli->query($sqlUv." WHERE `name` LIKE '进入练习五' ".$riQiWhere." ");
$getUv=$query->fetch_assoc();
$lianXi['lx5']=array('pv'=>$getPv['c'],'uv'=>$getUv['c']);


$query=$mysqli->query($sqlPv." WHERE `name` LIKE '进入练习六' ".$riQiWhere." ");
$getPv=$query->fetch_assoc();
$query=$mysqli->query($sqlUv." WHERE `name` LIKE '进入练习六' ".$riQiWhere." ");
$getUv=$query->fetch_assoc();
$lianXi['lx6']=array('pv'=>$getPv['c'],'uv'=>$getUv['c']);

$query=$mysqli->query("SELECT id FROM tongj where theday='".$theday."' limit 0,1 ");
if($query->num_rows>0){}else{
    $mysqli->query("insert into tongj(theday,createtime) values('".$theday."','".date("Y-m-d H:i:s")."')  ");
}
//所有页面pv uv 统计
$mysqli->query("update tongj set allpage='".json_encode($lianXi)."' where theday='".$theday."' ");
 


$sqlPv="SELECT count(openid) as c FROM `q1`   ";
$sqlUv="SELECT count(DISTINCT openid) c FROM `q1`  ";
//12道题 pv uv 统计
$query=$mysqli->query($sqlPv." WHERE `t11` IS NOT NULL and `createtime` LIKE '%".$theday."%' ");
$getPv=$query->fetch_assoc();
$query=$mysqli->query($sqlUv." WHERE `t11` IS NOT NULL and `createtime` LIKE '%".$theday."%' ");
$getUv=$query->fetch_assoc();
$ti12=array('pv'=>$getPv['c'],'uv'=>$getUv['c']);
$mysqli->query("update tongj set ti12='".json_encode($ti12)."'  where theday='".$theday."'   ");

//echo $getPv['c'];echo '.................';
//echo $getUv['c'];


$sqlPv="SELECT count(openid) as c FROM `baidu` ";
$sqlUv="SELECT count(DISTINCT openid) c FROM `baidu` ";
//图片保存 pv uv 统计
$lianXi=array();
echo "<br />";
echo $sqlPv." WHERE `name` LIKE '%练习一保存图片%' ".$riQiWhere."  ";
echo "<br />";
$query=$mysqli->query($sqlPv." WHERE `name` LIKE '%练习一保存图片%' ".$riQiWhere."  ");
$getPv=$query->fetch_assoc();
$query=$mysqli->query($sqlUv." WHERE `name` LIKE '%练习一保存图片%' ".$riQiWhere." ");
$getUv=$query->fetch_assoc();
$lianXi[]=array('saveimage1' => array('pv'=>$getPv['c'],'uv'=>$getUv['c']) );


$query=$mysqli->query($sqlPv." WHERE `name` LIKE '%练习二保存图片%' ".$riQiWhere." ");
$getPv=$query->fetch_assoc();
$query=$mysqli->query($sqlUv." WHERE `name` LIKE '%练习二保存图片%' ".$riQiWhere." ");
$getUv=$query->fetch_assoc();
$lianXi[]=array('saveimage2' => array('pv'=>$getPv['c'],'uv'=>$getUv['c']) );


$query=$mysqli->query($sqlPv." WHERE `name` LIKE '%练习四保存图片%'  ".$riQiWhere." ");
$getPv=$query->fetch_assoc();
$query=$mysqli->query($sqlUv." WHERE `name` LIKE '%练习四保存图片%'  ".$riQiWhere." ");
$getUv=$query->fetch_assoc();
$lianXi[]=array('saveimage4' => array('pv'=>$getPv['c'],'uv'=>$getUv['c']) );


$mysqli->query("update tongj set image='".json_encode($lianXi)."'  where theday='".$theday."'   ");
 
$mysqli->close();





